package initialize

import (
	"fmt"
	"reward-server/global"

	"github.com/ethereum/go-ethereum/ethclient"
	"go.uber.org/zap"
)

func InitEth() {

	// url := "https://sepolia.infura.io/v3/" + GetInfuraKey() //这里使用sepolia，mainnet经常连不上
	url := fmt.Sprintf("%v%v", global.ServerConfig.Eth.Url, global.ServerConfig.Eth.Key)
	client, err := ethclient.Dial(url)
	if err != nil {

		zap.S().Errorf("连接Ethereum节点失败%s", err)
		panic(err)
	}
	zap.S().Info("连接Ethereum节点成功:%+v", client)
	global.Ethclient = client
}
